﻿using System;
using System.Windows.Forms;
using Scommesse.Presenters;

namespace Scommesse.View
{
    public partial class InserimentoTessera : Form
    {
        IInserimentoTesseraPresenter _presenter;

        public InserimentoTessera()
        {
            InitializeComponent();
        }

        public void AddListener(IInserimentoTesseraPresenter presenter)
        {
            _presenter = presenter;
        }

        private void InserisciButton_Click(object sender, EventArgs e)
        {
            _presenter.InserisciTessera();
        }

        private void CodiceBetCardTextBox_Click(object sender, EventArgs e)
        {
            _presenter.ClearTextBox();
        }

        private void InserimentoTessera_Activated(object sender, EventArgs e)
        {
            _presenter.SetTextBoxOnActivate();
        }

        private void CodiceBetCardTextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                _presenter.InserisciTessera();
        }

        public String CodiceTessera
        {
            get { return codiceBetCardTextBox.Text; }
            set { codiceBetCardTextBox.Text = value; }
        }

        public bool ErrorVisible
        {
            get { return labelError.Visible; }
            set { labelError.Visible = value; }
        }
    }
}